home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Wizard.java < prev    next >
Text File  |  1998-10-25  |  18KB  |  838 lines

  1. package com.symantec.itools.frameworks.wizard;
  2.  
  3.  
  4. import java.awt.*;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.KeyEvent;
  7. import java.awt.event.ActionListener;
  8. import java.io.InputStream;
  9. import java.io.IOException;
  10. import java.net.URL;
  11. import java.util.Enumeration;
  12. import java.util.ResourceBundle;
  13. import java.util.Vector;
  14. import java.util.Locale;
  15. import com.sun.java.swing.JComponent;
  16. import com.sun.java.swing.JButton;
  17. import com.sun.java.swing.AbstractButton;
  18. import com.sun.java.swing.JPanel;
  19. import com.sun.java.swing.UIManager;
  20. import com.sun.java.swing.JLabel;
  21. import com.sun.java.swing.border.LineBorder;
  22. import com.sun.java.swing.KeyStroke;
  23. import com.symantec.itools.swing.icons.ImageIcon;
  24. import com.symantec.itools.util.ResourceBundleAdapter;
  25.  
  26.  
  27. /**
  28.  * @author Symantec Internet Tools Division
  29.  * @version 1.0
  30.  * @since VCafe 3.0
  31.  */
  32. public class Wizard
  33.     extends JPanel
  34. {
  35.     protected static ResourceBundle defaultResourceBundle;
  36.  
  37.     protected JPanel displayPanel;
  38.     protected JPanel pagesPanel;
  39.     protected JPanel actionPanel;
  40.     protected JPanel separatorPanel;
  41.     protected JPanel buttonsPanel;
  42.     protected JLabel imageLbl;
  43.     protected JLabel separatorLbl;
  44.     protected JButton backBtn;
  45.     protected JButton nextBtn;
  46.     protected JButton finishBtn;
  47.     protected JButton cancelBtn;
  48.     protected JButton helpBtn;
  49.     protected ImageIcon imageIcon;
  50.     protected ImageIcon separatorIcon;
  51.     protected ResourceBundleAdapter resourceBundle;
  52.     protected KeyAction keyAction;
  53.     protected boolean addEnterKeyAction;
  54.  
  55.     /**
  56.      * @since VCafe 3.0
  57.      */
  58.     protected WizardController controller;
  59.  
  60.     /**
  61.      * @since VCafe 3.0
  62.      */
  63.     protected Vector listeners;
  64.  
  65.     /**
  66.      * @since VCafe 3.0
  67.      */
  68.     protected boolean showOnAddNotify;
  69.  
  70.     /**
  71.      * @since VCafe 3.0
  72.      */
  73.     protected boolean isInitialized;
  74.  
  75.     static
  76.     {
  77.         try
  78.         {
  79.             defaultResourceBundle = ResourceBundle.getBundle("com.symantec.itools.frameworks.wizard.WizardBundle");
  80.         }
  81.         catch(Throwable ex)
  82.         {
  83.             ex.printStackTrace();
  84.         }
  85.     }
  86.  
  87.     {
  88.         listeners       = new Vector();
  89.         showOnAddNotify = true;
  90.         keyAction       = null;
  91.         addEnterKeyAction = false;
  92.     }
  93.  
  94.     public Wizard()
  95.     {
  96.         this(defaultResourceBundle);
  97.     }
  98.     
  99.     public Wizard(ResourceBundle bundle)
  100.     {
  101.         this(bundle, null);
  102.     }
  103.  
  104.     public Wizard(WizardController controller)
  105.     {
  106.         this(defaultResourceBundle, null);
  107.     }
  108.  
  109.     public Wizard(ResourceBundle bundle, WizardController c)
  110.     {
  111.         GridBagLayout gridBagLayout;
  112.  
  113.         resourceBundle = new ResourceBundleAdapter(bundle);
  114.         
  115.         if(c == null)
  116.         {
  117.             c = new WizardController(this);
  118.         }
  119.         
  120.         controller    = c;
  121.         isInitialized = false;
  122.         setLayout(new BorderLayout(0,0));
  123.         setSize(332,248);
  124.         gridBagLayout = new GridBagLayout();
  125.  
  126.         displayPanel = new JPanel();
  127.         displayPanel.setLayout(new GridBagLayout());
  128.         add("Center", displayPanel);
  129.         
  130.         imageIcon = new ImageIcon();
  131.         imageLbl  = new JLabel();
  132.         imageLbl.setDisabledIcon(imageIcon);
  133.         imageLbl.setIcon(imageIcon);        
  134.         displayPanel.add(imageLbl, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,-1.0,1.0,java.awt.GridBagConstraints.NORTHWEST,java.awt.GridBagConstraints.BOTH,new Insets(6,6,0,0),0,0));
  135.         imageLbl.setVisible(false);
  136.                 
  137.         pagesPanel = new JPanel();
  138.         pagesPanel.setLayout(new GridLayout(1,1,0,0));
  139.         displayPanel.add(pagesPanel, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,1.0,1.0,java.awt.GridBagConstraints.NORTHEAST,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  140.  
  141.         actionPanel = new JPanel();
  142.         actionPanel.setLayout(gridBagLayout);
  143.         add("South", actionPanel);
  144.  
  145.         separatorPanel = new JPanel();
  146.         separatorPanel.setLayout(new GridLayout(1,1,0,0));
  147.         actionPanel.add(separatorPanel, new com.symantec.itools.awt.GridBagConstraintsD(0,0,0,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,6,0,0),0,0));
  148.  
  149.         try
  150.         {
  151.             separatorIcon = new ImageIcon(Wizard.class.getResourceAsStream("Separator.gif"));
  152.         }
  153.         catch(IOException ex)
  154.         {
  155.         }
  156.  
  157.         separatorLbl = new JLabel();
  158.         separatorLbl.setDisabledIcon(separatorIcon);
  159.         separatorLbl.setIcon(separatorIcon);
  160.         separatorPanel.add(separatorLbl);
  161.         separatorLbl.setVisible(false);
  162.  
  163.         buttonsPanel = new JPanel();
  164.         buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5));
  165.         actionPanel.add(buttonsPanel, new com.symantec.itools.awt.GridBagConstraintsD(1,1,0,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  166.  
  167.         backBtn = new JButton();
  168.         buttonsPanel.add(backBtn);
  169.         nextBtn = new JButton();
  170.         buttonsPanel.add(nextBtn);
  171.         finishBtn = new JButton();
  172.         buttonsPanel.add(finishBtn);
  173.         cancelBtn = new JButton();
  174.         buttonsPanel.add(cancelBtn);
  175.         helpBtn = new JButton();
  176.         buttonsPanel.add(helpBtn);
  177.         setupButton(backBtn, "BACK");
  178.         setupButton(nextBtn, "NEXT");
  179.         setupButton(finishBtn, "FINISH");
  180.         setupButton(cancelBtn, "CANCEL");
  181.         setupButton(helpBtn, "HELP");
  182.  
  183.         SymAction lSymAction = new SymAction();
  184.         backBtn.addActionListener(lSymAction);
  185.         nextBtn.addActionListener(lSymAction);
  186.         finishBtn.addActionListener(lSymAction);
  187.         cancelBtn.addActionListener(lSymAction);
  188.         helpBtn.addActionListener(lSymAction);
  189.         isInitialized = true;
  190.     }
  191.  
  192.     private void setupButton(JButton btn, String base)
  193.     {
  194.         String toolTipText;
  195.         
  196.         btn.setText(resourceBundle.getString(base + "_BTN_TEXT", "< Prev"));        
  197.         btn.setMnemonic(resourceBundle.getChar(base + "_BTN_MNEMONIC"));
  198.         btn.setActionCommand(resourceBundle.getString(base + "_BTN_ACTION", "prev"));
  199.         toolTipText = resourceBundle.getString(base + "_BTN_TOOLTIP", "");
  200.         
  201.         if(!(toolTipText.equals("")))
  202.         {
  203.             btn.setToolTipText(toolTipText);
  204.         }
  205.     }
  206.     
  207.     /**
  208.      * @since VCafe 3.0
  209.      */
  210.     public void setAddEnterKeyAction(boolean addEnterKeyAction)
  211.     {
  212.         this.addEnterKeyAction = addEnterKeyAction;
  213.     }
  214.     
  215.     public boolean getAddEnterKeyAction()
  216.     {
  217.         return addEnterKeyAction;
  218.     }
  219.  
  220.     /**
  221.      * @since VCafe 3.0
  222.      */
  223.  
  224.     public void addNotify()
  225.     {
  226.         super.addNotify();
  227.  
  228.         if(showOnAddNotify && controller != null)
  229.         {
  230.             controller.init();
  231.         }
  232.  
  233.         // Hookup keyboard listeners.
  234.         if (addEnterKeyAction && keyAction == null)
  235.         {
  236.             keyAction = new KeyAction();
  237.             registerKeyboardAction(keyAction, "enter pressed", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
  238.         }
  239.     }
  240.  
  241.     /**
  242.      * It has been overridden here to unhook listeners.
  243.      * @since VCafe 3.0
  244.      */
  245.     public void removeNotify()
  246.     {
  247.         super.removeNotify();
  248.         
  249.         if (keyAction != null)
  250.         {
  251.             unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
  252.             unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
  253.             keyAction = null;
  254.         }
  255.     }
  256.  
  257.     /**
  258.      * @param c TODO
  259.      * @since VCafe 3.0
  260.      */
  261.     public void setWizardController(WizardController c)
  262.     {
  263.         controller = c;
  264.     }
  265.  
  266.     /**
  267.      * @param lm TODO
  268.      * @since VCafe 3.0
  269.      */
  270.     public void setLayout(LayoutManager lm)
  271.     {
  272.         if(!(isInitialized))
  273.         {
  274.             super.setLayout(lm);
  275.         }
  276.     }
  277.  
  278.     /**
  279.      * @param comp TODO
  280.      * @since VCafe 3.0
  281.      */
  282.     public void addImpl(Component comp, Object constraints, int index)
  283.     {
  284.         if(isInitialized)
  285.         {
  286.             if(controller != null)
  287.             {
  288.                 if(comp instanceof JPanel)
  289.                 {
  290.                     controller.addPanel((JPanel)comp);
  291.                 }
  292.             }
  293.         }
  294.         else
  295.         {
  296.             super.addImpl(comp, constraints, index);
  297.         }
  298.     }
  299.  
  300.     /**
  301.      * @param panel TODO
  302.      * @since VCafe 3.0
  303.      */
  304.     protected void showPanel(JPanel panel)
  305.     {
  306.         String      panelTitle;
  307.         String      wizardTitle;
  308.         WizardEvent event;
  309.  
  310.         wizardTitle = null;
  311.         panelTitle  = null;
  312.  
  313.         if(pagesPanel.getComponentCount() > 0)
  314.         {
  315.             if(!(panel.equals(pagesPanel.getComponent(0))))
  316.             {
  317.                 pagesPanel.remove(pagesPanel.getComponent(0));
  318.                 pagesPanel.add(panel);
  319.                 pagesPanel.validate();
  320.             }
  321.         }
  322.         else
  323.         {
  324.             pagesPanel.add(panel);
  325.         }
  326.  
  327.         repaint();
  328.  
  329.         if(panel instanceof WizardPage)
  330.         {
  331.             panelTitle = ((WizardPage)panel).getPanelTitle();
  332.         }
  333.  
  334.         if(controller != null)
  335.         {
  336.             wizardTitle = controller.getWizardTitle();
  337.         }
  338.  
  339.         if(wizardTitle == null)
  340.         {
  341.             wizardTitle = "Wizard";
  342.         }
  343.  
  344.         if(panelTitle != null && panelTitle.length() > 0)
  345.         {
  346.             wizardTitle += " - " + panelTitle;
  347.         }
  348.  
  349.         event = new WizardEvent(this, WizardEvent.WIZARD_TITLE_CHANGED);
  350.         event.setNewTitle(wizardTitle);
  351.         fireWizardEvent(event);
  352.     }
  353.  
  354.     /**
  355.      * @author Symantec Internet Tools Division
  356.      * @version 1.0
  357.      * @since VCafe 3.0
  358.      */
  359.  
  360.     class SymAction
  361.         implements ActionListener
  362.     {
  363.  
  364.         /**
  365.          * @param event TODO
  366.          * @since VCafe 3.0
  367.          */
  368.         public void actionPerformed(ActionEvent event)
  369.         {
  370.             Object object;
  371.  
  372.             object = event.getSource();
  373.  
  374.             if(object == backBtn)
  375.             {
  376.                 backBtnActionPerformed(event);
  377.             }
  378.             else if(object == nextBtn)
  379.             {
  380.                 nextBtnActionPerformed(event);
  381.             }
  382.             else if(object == finishBtn)
  383.             {
  384.                 finishBtnActionPerformed(event);
  385.             }
  386.             else if(object == cancelBtn)
  387.             {
  388.                 cancelBtnActionPerformed(event);
  389.             }
  390.             else if(object == helpBtn)
  391.             {
  392.                 helpBtnActionPerformed(event);
  393.             }
  394.         }
  395.     }
  396.  
  397.     /**
  398.      * KeyAction
  399.      * @since VCafe 3.0
  400.      */
  401.     public class KeyAction implements java.awt.event.ActionListener
  402.     {
  403.         /**
  404.          * Handles Action Events associated with registered keyboard actions.
  405.          */
  406.         public void actionPerformed(java.awt.event.ActionEvent event)
  407.         {
  408.             String command = event.getActionCommand();
  409.             
  410.             if (command.equals("enter pressed")) {
  411.                 if (isNextEnabled()) {
  412.                     nextBtnActionPerformed(null);
  413.                 } else if (isFinishEnabled()) {
  414.                     finishBtnActionPerformed(null);
  415.                 }
  416.             }
  417.         }
  418.     }
  419.  
  420.     /**
  421.      * @param event TODO
  422.      * @since VCafe 3.0
  423.      */
  424.  
  425.     void backBtnActionPerformed(ActionEvent event)
  426.     {
  427.         if(controller != null)
  428.         {
  429.             controller.backPanel();
  430.         }
  431.     }
  432.  
  433.     /**
  434.      * @param event TODO
  435.      * @since VCafe 3.0
  436.      */
  437.  
  438.     void nextBtnActionPerformed(ActionEvent event)
  439.     {
  440.         if(controller != null)
  441.         {
  442.             controller.nextPanel();
  443.         }
  444.     }
  445.  
  446.     /**
  447.      * @param event TODO
  448.      * @since VCafe 3.0
  449.      */
  450.  
  451.     void finishBtnActionPerformed(ActionEvent event)
  452.     {
  453.         finish();
  454.     }
  455.  
  456.     /**
  457.      * @param event TODO
  458.      * @since VCafe 3.0
  459.      */
  460.  
  461.     void cancelBtnActionPerformed(ActionEvent event)
  462.     {
  463.         cancel();
  464.     }
  465.  
  466.     /**
  467.      * @param event TODO
  468.      * @since VCafe 3.0
  469.      */
  470.  
  471.     void helpBtnActionPerformed(ActionEvent event)
  472.     {
  473.         if(controller != null)
  474.         {
  475.             controller.help();
  476.         }
  477.     }
  478.  
  479.     /**
  480.      * @param f TODO
  481.      * @since VCafe 3.0
  482.      */
  483.  
  484.     public void setBackEnabled(boolean f)
  485.     {
  486.         enableButton(backBtn, f);
  487.     }
  488.  
  489.     /**
  490.      * @param f TODO
  491.      * @since VCafe 3.0
  492.      */
  493.  
  494.     public void setNextEnabled(boolean f)
  495.     {
  496.         enableButton(nextBtn, f);
  497.     }
  498.  
  499.     /**
  500.      * @param f TODO
  501.      * @since VCafe 3.0
  502.      */
  503.  
  504.     public void setFinishEnabled(boolean f)
  505.     {
  506.         enableButton(finishBtn, f);
  507.     }
  508.  
  509.     /**
  510.      * @param f TODO
  511.      * @since VCafe 3.0
  512.      */
  513.  
  514.     public void setCancelEnabled(boolean f)
  515.     {
  516.         enableButton(cancelBtn, f);
  517.     }
  518.  
  519.     /**
  520.      * @param f TODO
  521.      * @since VCafe 3.0
  522.      */
  523.  
  524.     public void setHelpEnabled(boolean f)
  525.     {
  526.         enableButton(helpBtn, f);
  527.     }
  528.  
  529.     /**
  530.      * @param b TODO
  531.      * @param f TODO
  532.      * @since VCafe 3.0
  533.      */
  534.  
  535.     private void enableButton(AbstractButton b, boolean f)
  536.     {
  537.         b.setEnabled(f);
  538.         b.setFocusPainted(f);
  539.     }
  540.  
  541.     /**
  542.      * @since VCafe 3.0
  543.      */
  544.  
  545.     public boolean isBackEnabled()
  546.     {
  547.         return (backBtn.isEnabled());
  548.     }
  549.  
  550.     /**
  551.      * @since VCafe 3.0
  552.      */
  553.  
  554.     public boolean isNextEnabled()
  555.     {
  556.         return (nextBtn.isEnabled());
  557.     }
  558.  
  559.     /**
  560.      * @since VCafe 3.0
  561.      */
  562.  
  563.     public boolean isFinishEnabled()
  564.     {
  565.         return (finishBtn.isEnabled());
  566.     }
  567.  
  568.     /**
  569.      * @since VCafe 3.0
  570.      */
  571.  
  572.     public boolean isCancelEnabled()
  573.     {
  574.         return (cancelBtn.isEnabled());
  575.     }
  576.  
  577.     /**
  578.      * @since VCafe 3.0
  579.      */
  580.  
  581.     public boolean isHelpEnabled()
  582.     {
  583.         return (helpBtn.isEnabled());
  584.     }
  585.  
  586.     /**
  587.      * @since VCafe 3.0
  588.      */
  589.  
  590.     public void setBackFocus()
  591.     {
  592.         backBtn.requestFocus();
  593.     }
  594.  
  595.     /**
  596.      * @since VCafe 3.0
  597.      */
  598.  
  599.     public void setNextFocus()
  600.     {
  601.         nextBtn.requestFocus();
  602.     }
  603.  
  604.     /**
  605.      * @since VCafe 3.0
  606.      */
  607.  
  608.     public void setFinishFocus()
  609.     {
  610.         finishBtn.requestFocus();
  611.     }
  612.  
  613.     /**
  614.      * @since VCafe 3.0
  615.      */
  616.  
  617.     public void setCancelFocus()
  618.     {
  619.         cancelBtn.requestFocus();
  620.     }
  621.  
  622.     /**
  623.      * @since VCafe 3.0
  624.      */
  625.  
  626.     public void setHelpFocus()
  627.     {
  628.         helpBtn.requestFocus();
  629.     }
  630.  
  631.     /**
  632.      * @since VCafe 3.0
  633.      */
  634.  
  635.     public void finish()
  636.     {
  637.         if(controller != null)
  638.         {
  639.             controller.finish();
  640.         }
  641.  
  642.         fireWizardEvent(new WizardEvent(this, WizardEvent.WIZARD_FINISH_REQUESTED));
  643.     }
  644.  
  645.     /**
  646.      * @since VCafe 3.0
  647.      */
  648.  
  649.     public void finishSuccessful()
  650.     {
  651.         fireWizardEvent(new WizardEvent(this, WizardEvent.WIZARD_FINISHED_SUCCESSFULLY));
  652.     }
  653.  
  654.     /**
  655.      * @since VCafe 3.0
  656.      */
  657.  
  658.     public void cancel()
  659.     {
  660.         if(controller != null)
  661.         {
  662.             controller.cancel();
  663.         }
  664.  
  665.         fireWizardEvent(new WizardEvent(this, WizardEvent.WIZARD_CANCEL));
  666.     }
  667.  
  668.     /**
  669.      * @param listener TODO
  670.      * @since VCafe 3.0
  671.      */
  672.  
  673.     public void addWizardListener(WizardListener listener)
  674.     {
  675.         if(!(listeners.contains(listener)))
  676.         {
  677.             listeners.addElement(listener);
  678.         }
  679.     }
  680.  
  681.     /**
  682.      * @param listener TODO
  683.      * @since VCafe 3.0
  684.      */
  685.  
  686.     public void removeWizardListener(WizardListener listener)
  687.     {
  688.         if(listeners.contains(listener))
  689.         {
  690.             listeners.removeElement(listener);
  691.         }
  692.     }
  693.  
  694.     /**
  695.      * @param event TODO
  696.      * @since VCafe 3.0
  697.      */
  698.  
  699.     protected void fireWizardEvent(WizardEvent event)
  700.     {
  701.         Vector tempListeners;
  702.  
  703.         synchronized(listeners)
  704.         {
  705.             tempListeners = (Vector)listeners.clone();
  706.         }
  707.  
  708.         switch(event.getID())
  709.         {
  710.             case WizardEvent.WIZARD_FINISH_REQUESTED:
  711.             {
  712.                 for(Enumeration e = listeners.elements(); e.hasMoreElements();)
  713.                 {
  714.                     ((WizardListener)e.nextElement()).wizardFinishRequested(event);
  715.                 }
  716.  
  717.                 break;
  718.             }
  719.             case WizardEvent.WIZARD_FINISHED_SUCCESSFULLY:
  720.             {
  721.                 for(Enumeration e = listeners.elements(); e.hasMoreElements();)
  722.                 {
  723.                     ((WizardListener)e.nextElement()).wizardFinishedSuccessfully(event);
  724.                 }
  725.  
  726.                 break;
  727.             }
  728.             case WizardEvent.WIZARD_CANCEL:
  729.             {
  730.                 for(Enumeration e = listeners.elements(); e.hasMoreElements();)
  731.                 {
  732.                     ((WizardListener)e.nextElement()).wizardCanceled(event);
  733.                 }
  734.  
  735.                 break;
  736.             }
  737.             case WizardEvent.WIZARD_TITLE_CHANGED:
  738.             {
  739.                 for(Enumeration e = listeners.elements(); e.hasMoreElements();)
  740.                 {
  741.                     ((WizardListener)e.nextElement()).wizardTitleChanged(event);
  742.                 }
  743.  
  744.                 break;
  745.             }
  746.         }
  747.     }
  748.  
  749.     /**
  750.      * @since VCafe 3.0
  751.      */
  752.     public Frame getParentFrame()
  753.     {
  754.         Container parent;
  755.         Frame     frame;
  756.  
  757.         parent = getParent();
  758.         frame  = null;
  759.  
  760.         while(parent != null)
  761.         {
  762.             if(parent == null)
  763.             {
  764.                 break;
  765.             }
  766.             else if(parent instanceof Frame)
  767.             {
  768.                 frame = (Frame) parent;
  769.             }
  770.  
  771.             parent = parent.getParent();
  772.         }
  773.  
  774.         return frame;
  775.     }
  776.  
  777.     /**
  778.      * @param visible TODO
  779.      * @since VCafe 3.0
  780.      */
  781.     public void setSeparatorVisible(boolean visible)
  782.     {
  783.         separatorLbl.setVisible(visible);
  784.     }
  785.  
  786.     /**
  787.      * @since VCafe 3.0
  788.      */
  789.     public boolean isSeparatorVisible()
  790.     {
  791.         return separatorLbl.isVisible();
  792.     }
  793.  
  794.     public Dimension getMinimumSize()
  795.     {
  796.         return (getPreferredSize());
  797.     }
  798.  
  799.     public Dimension getPreferredSize()
  800.     {
  801.         return (new Dimension(480, 345));
  802.     }
  803.     
  804.     public void setImage(Image image)
  805.     {
  806.         setImage(new ImageIcon(image));
  807.     }
  808.     
  809.     public void setImage(URL url)
  810.     {
  811.         setImage(new ImageIcon(url));
  812.     }
  813.     
  814.     public void setImage(InputStream stream)
  815.         throws IOException
  816.     {
  817.           setImage(new ImageIcon(stream));
  818.     }
  819.     
  820.     public void setImage(ImageIcon icon)
  821.     {
  822.         imageIcon = icon;
  823.         
  824.         if(icon != null)
  825.         {
  826.             imageLbl.setDisabledIcon(imageIcon);
  827.             imageLbl.setIcon(imageIcon);
  828.             imageLbl.setVisible(true);
  829.             displayPanel.validate();
  830.         }
  831.         else
  832.         {
  833.             imageLbl.setVisible(false);
  834.         }
  835.         
  836.         repaint();
  837.     }
  838. }